<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>登录</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

    <!-- jquery -->
    <script type="text/javascript" th:src="@{/js/jquery.min.js}"></script>
    <!-- bootstrap -->
    <link rel="stylesheet" type="text/css" th:href="@{/bootstrap/css/bootstrap.min.css}"/>

    <link rel="stylesheet" type="text/css" th:href="@{/css/login.css}"/>

    <style>
        .form-control{
            font-size: 10px !important;
        }
        .error{
            font-size: 10px !important;
            color: red !important;
            font-weight:100 !important;
        }
    </style>
</head>
<body>
<div class="content">
    <div class="title">
        <h4>用户登录</h4>
    </div>

    <form name="loginForm" id="loginForm" method="post">
        <div class="form-group">
            <input id="mobile" name="mobile" class="form-control" type="text" placeholder="手机号码" required="true"
                   minlength="11" maxlength="11"/>
        </div>

        <div class="form-group">
            <input id="password" name="password" class="form-control" type="password" placeholder="密码"
                   required="true" minlength="6" maxlength="16"/>
        </div>
        <button class="btn btn-primary btn-block" type="submit" onclick="login()">登录</button>
    </form>

</div>
</body>
<script type="text/javascript" th:src="@{/bootstrap/js/bootstrap.min.js}"></script>
<!-- jquery-validator -->
<script type="text/javascript" th:src="@{/jquery-validation/jquery.validate.min.js}"></script>
<script type="text/javascript" th:src="@{/jquery-validation/localization/messages_zh.min.js}"></script>
<!-- layer -->
<script type="text/javascript" th:src="@{/layer/layer.js}"></script>
<!-- md5.js -->
<script type="text/javascript" th:src="@{/js/md5.min.js}"></script>
<!-- common.js -->
<script type="text/javascript" th:src="@{/js/common.js}"></script>
<script>
    function login() {
        $("#loginForm").validate({
            submitHandler: function (form) {
                doLogin();
            }
        });
    }

    function doLogin() {
        g_showLoading();

        var inputPass = $("#password").val();
        var salt = g_passsword_salt;
        var str = "" + salt.charAt(0) + salt.charAt(2) + inputPass + salt.charAt(5) + salt.charAt(4);
        var password = md5(str);

        $.ajax({
            url: "/user/login",
            type: "POST",
            data: {
                mobile: $("#mobile").val(),
                password: password
            },
            success: function (data) {
                layer.closeAll();
                if (data.code == 0) {
                    layer.msg("成功");
                    window.location.href = "http://192.168.137.1:8080/mall/index.html";
                } else {
                    layer.msg(data.msg);
                }
            },
            error: function () {
                layer.closeAll();
            }
        });
    }
</script>
</html>
<!--<!DOCTYPE HTML>-->
<!--<html lang="en" xmlns:th="http://www.thymeleaf.org">-->
<!--<head>-->
<!--    <meta charset="UTF-8"/>-->
<!--    <title>Login</title>-->
<!--    <link rel="stylesheet" th:href="@{/css/qingzhu0.css}"/>-->
<!--    <link rel="stylesheet" th:href="@{/css/login.css}"/>-->
<!--    <link rel="stylesheet" th:href="@{/iconfont/iconfont.css}"/>-->
<!--    <link rel="stylesheet" th:href="@{/css/qingzhu6.css}"/>-->
<!--    <link rel="stylesheet" th:href="@{/css/common.css}"/>-->
<!--    <link rel="stylesheet" th:href="@{/layui/css/layui.css}"/>-->
<!--</head>-->
<!--<body>-->
<!--<div th:replace="common::header"></div>-->
<!--<div class="outer6">-->
<!--    <h4>用户登录</h4>-->
<!--    <form class="layui-form" method="post">-->
<!--        <div class="layui-form-item">-->
<!--            <div class="div">-->
<!--                <input type="text" name="name" lay-verify="required"/>-->
<!--                <span id="s1">手机号</span>-->
<!--            </div>-->
<!--        </div>-->
<!--        <div class="layui-form-item">-->
<!--            <div  class="div">-->
<!--                <input type="password" name="password" lay-verify="required"/>-->
<!--                <span id="s2">登录密码</span>-->
<!--            </div>-->
<!--        </div>-->
<!--        <div class="layui-form-item">-->
<!--            <button lay-filter="login" type="submit" class="submit" onclick="login()">登录</button>-->
<!--        </div>-->
<!--    </form>-->
<!--</div>-->
<!--<div th:replace="common::footer"></div>-->
<!--<script th:src="@{/js/青竹登录.js}"></script>-->
<!--<script th:src="@{/js/jqurey.js}"></script>-->
<!--<script th:src="@{/js/shop.js}"></script>-->
<!--</body>-->
<!--<script th:src="@{/layui/layui.js}"></script>-->
<!--<script>-->
<!--    function login() {-->
<!--        $("#loginForm").validate({-->
<!--            submitHandler: function (form) {-->
<!--                doLogin();-->
<!--            }-->
<!--        });-->
<!--    }-->

<!--    function doLogin() {-->
<!--        g_showLoading();-->

<!--        var inputPass = $("#password").val();-->
<!--        var salt = g_passsword_salt;-->
<!--        var str = "" + salt.charAt(0) + salt.charAt(2) + inputPass + salt.charAt(5) + salt.charAt(4);-->
<!--        var password = md5(str);-->

<!--        $.ajax({-->
<!--            url: "/user/login",-->
<!--            type: "POST",-->
<!--            data: {-->
<!--                mobile: $("#mobile").val(),-->
<!--                password: password-->
<!--            },-->
<!--            success: function (data) {-->
<!--                layer.closeAll();-->
<!--                if (data.code == 0) {-->
<!--                    layer.msg("成功");-->
<!--                    window.location.href = "/goods/list";-->
<!--                } else {-->
<!--                    layer.msg(data.msg);-->
<!--                }-->
<!--            },-->
<!--            error: function () {-->
<!--                layer.closeAll();-->
<!--            }-->
<!--        });-->
<!--    }-->
<!--</script>-->
<!--</html>-->
